﻿using Common.BaseLibrary.Repositories;
using Common.Repositories.EF;
using DepartmentWork.Migrator;
using DepartmentWork.Migrator.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DepartmentWork.Platform.Controllers
{
    public class BaseController : Controller
    {
        protected readonly DepartmentWorkDbContext db;
        protected IExtensionRepository<TEAMSPACE> teamspaceRepository;
        protected IExtensionRepository<USER_INFO> userRepository;
        protected IExtensionRepository<USER_TEAMSAPCE> userTeamsapceRepository;
        protected IExtensionRepository<PROJECT_DEVELOP_BUG> projectDevelopBugRepository;
        protected IExtensionRepository<PROJECT_DEVELOP_TASK> projectDevelopTaskRepository;
        protected IExtensionRepository<PROJECT_DEVELOP> projectDevelopRepository;
        protected IExtensionRepository<PROJECT_DEVELOP_USER> projectDevelopUserRepository;
        protected IExtensionRepository<PROJECT_DEVELOP_DOCUMENT> projectDevelopDocumentRepository;
        //protected IExtensionRepository<PROJECT_DEVELOP_DOCUMENT_TYPE> projectDevelopDocumentTypeRepository;
        protected IExtensionRepository<FILEINFO> fileRepository;
        protected IExtensionRepository<PROJECT_DEVELOP_TASKBOOK> projectDevelopTaskBookRepository;
        protected IExtensionRepository<ROLE_INFO> roleRepository;
        protected IExtensionRepository<MENU> menuRepository;
        protected IExtensionRepository<MENU_ROLE> menuRoleRepository;

        protected IExtensionRepository<PROJECT_DESK_LEAVE> projectdeskleaveRepository;
        protected IExtensionRepository<PROJECT_DESK_WORK> projectdeskworkRepository;
        protected IExtensionRepository<PROJECT_DESK_WORKTIME> projectdeskworktimeRepository;
        protected IExtensionRepository<PROJECT_DESK_WORK_JOBLOGGING> projectdeskJoblogging;

        protected IExtensionRepository<PROJECT_MAINTENANCE_APPOPS> projectMaintenanceAppopsRepository;
        protected IExtensionRepository<PROJECT_MAINTENANCE_APPOPS_USER> projectMaintenanceAppopsUserRepository;
        protected IExtensionRepository<PROJECT_MAINTENANCE_DOCUMENT> projectMaintenanceDocumentRepository;
        protected IExtensionRepository<PROJECT_MAINTENANCE_RECORD> projectMaintenanceRecordRepository;
        protected IExtensionRepository<PROJECT_MANAGEMENT> projectManagementRepository;
        protected IExtensionRepository<PROJECT_WORKRECORD> projectWorkReocredRepository;

        protected IExtensionRepository<TEAMTRAIN> teamTrainRepository;

        protected IExtensionRepository<AUTHORITY_ROLE> authorityRoleRepository;
        protected IExtensionRepository<EMP_AUTHORITY> empAuthorityRepository;

        public BaseController()
        {
            db = new DepartmentWorkDbContext();
            teamspaceRepository = new DepartmentWorkEfRepository<TEAMSPACE>();
            userRepository = new DepartmentWorkEfRepository<USER_INFO>();
            userTeamsapceRepository = new DepartmentWorkEfRepository<USER_TEAMSAPCE>();
            projectDevelopBugRepository = new DepartmentWorkEfRepository<PROJECT_DEVELOP_BUG>();
            projectDevelopTaskRepository = new DepartmentWorkEfRepository<PROJECT_DEVELOP_TASK>();
            projectDevelopRepository = new DepartmentWorkEfRepository<PROJECT_DEVELOP>();
            projectDevelopUserRepository = new DepartmentWorkEfRepository<PROJECT_DEVELOP_USER>();
            projectDevelopDocumentRepository = new DepartmentWorkEfRepository<PROJECT_DEVELOP_DOCUMENT>();
            //projectDevelopDocumentTypeRepository = new DepartmentWorkEfRepository<PROJECT_DEVELOP_DOCUMENT_TYPE>();
            fileRepository = new DepartmentWorkEfRepository<FILEINFO>();
            projectDevelopTaskBookRepository = new DepartmentWorkEfRepository<PROJECT_DEVELOP_TASKBOOK>();
            projectdeskleaveRepository = new DepartmentWorkEfRepository<PROJECT_DESK_LEAVE>();
            projectdeskworkRepository = new DepartmentWorkEfRepository<PROJECT_DESK_WORK>();
            projectdeskworktimeRepository = new DepartmentWorkEfRepository<PROJECT_DESK_WORKTIME>();
            roleRepository = new DepartmentWorkEfRepository<ROLE_INFO>();
            menuRepository = new DepartmentWorkEfRepository<MENU>();
            menuRoleRepository = new DepartmentWorkEfRepository<MENU_ROLE>();
            projectMaintenanceAppopsRepository = new DepartmentWorkEfRepository<PROJECT_MAINTENANCE_APPOPS>();
            projectMaintenanceAppopsUserRepository = new DepartmentWorkEfRepository<PROJECT_MAINTENANCE_APPOPS_USER>();
            projectMaintenanceDocumentRepository = new DepartmentWorkEfRepository<PROJECT_MAINTENANCE_DOCUMENT>();
            projectMaintenanceRecordRepository = new DepartmentWorkEfRepository<PROJECT_MAINTENANCE_RECORD>();

            projectManagementRepository=new DepartmentWorkEfRepository<PROJECT_MANAGEMENT>();
            projectWorkReocredRepository=new DepartmentWorkEfRepository<PROJECT_WORKRECORD>();


            projectdeskJoblogging = new DepartmentWorkEfRepository<PROJECT_DESK_WORK_JOBLOGGING>();

            teamTrainRepository=new DepartmentWorkEfRepository<TEAMTRAIN>();

            authorityRoleRepository=new EFRepository<AUTHORITY_ROLE>();
            empAuthorityRepository=new DepartmentWorkEfRepository<EMP_AUTHORITY>();

            teamspaceRepository.SetDataContext(db);
            userRepository.SetDataContext(db);
            userTeamsapceRepository.SetDataContext(db);
            projectDevelopBugRepository.SetDataContext(db);
            projectDevelopTaskRepository.SetDataContext(db);
            projectDevelopRepository.SetDataContext(db);
            projectDevelopUserRepository.SetDataContext(db);
            projectDevelopDocumentRepository.SetDataContext(db);
            //projectDevelopDocumentTypeRepository.SetDataContext(db);
            fileRepository.SetDataContext(db);
            projectDevelopTaskBookRepository.SetDataContext(db);
            projectdeskleaveRepository.SetDataContext(db);
            projectdeskworkRepository.SetDataContext(db);
            projectdeskworktimeRepository.SetDataContext(db);
            roleRepository.SetDataContext(db);
            menuRepository.SetDataContext(db);
            menuRoleRepository.SetDataContext(db);

            projectMaintenanceAppopsRepository.SetDataContext(db);
            projectMaintenanceDocumentRepository.SetDataContext(db);
            projectMaintenanceRecordRepository.SetDataContext(db);
            projectMaintenanceAppopsUserRepository.SetDataContext(db);


            projectManagementRepository.SetDataContext(db);
            projectWorkReocredRepository.SetDataContext(db);

            projectdeskJoblogging.SetDataContext(db);
            teamTrainRepository.SetDataContext(db);
            authorityRoleRepository.SetDataContext(db);
            empAuthorityRepository.SetDataContext(db);

        }
    }
}